package cn.humaohua.study.yanmo_design_pattern.ch12.v1;

import java.util.ArrayList;
import java.util.List;

public class Subject {
    protected List<Observer> readers = new ArrayList<Observer>();

    public void attach(Observer reader) {
        this.readers.add(reader);
    }

    public void detach(Observer reader) {
        this.readers.remove(reader);
    }

    public void notifyObserver() {
        for (Observer reader : readers)
            reader.update(this);
    }
}
